package com.jjyd.crlp.controller;

import com.jjyd.crlp.interceptor.dto.JWTDto;
import com.jjyd.crlp.model.base.ResultModel;
import com.jjyd.crlp.model.dto.tech.WordDto;
import com.jjyd.crlp.services.TechService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 用户登陆
 */
@RestController
@RequestMapping("/tech")
@Api(description = "技术后台接口")
public class TechController {

    @Autowired
    private TechService techService;

    /**
     * 添加单词
     * @param wordDto 单词内容
     * @return 返回添加单词的id
     */
    @PostMapping("/addWord")
    @ApiOperation(value = "添加单词")
    public ResultModel<Integer> addWord(WordDto wordDto) {
        wordDto.setId(null);
        Integer id = techService.addWord(wordDto);
        return new ResultModel<>(id);
    }

    /**
     * 获取新闻
     * @return
     */
    @PostMapping("/getNews")
    @ApiOperation(value = "获取新闻")
    public ResultModel<Boolean> getNews() {
        Boolean news = techService.getNews();
        return new ResultModel<>(news);
    }
}
